package com.groupseven.happycampus.controller;

import com.groupseven.happycampus.common.pojo.Commodity;
import com.groupseven.happycampus.common.pojo.OwnCommodity;
import com.groupseven.happycampus.common.result.R;
import com.groupseven.happycampus.common.vo.LayuiPageVo;
import com.groupseven.happycampus.service.OwnCommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("ownCommodity")
public class OwnCommodityController {
    //增删改查
    @Autowired
    private OwnCommodityService ownCommodityService;


    @RequestMapping("/ownCommodityList")
    public LayuiPageVo<OwnCommodity> commodityLayuiPageVoList(@RequestParam Map<String, Object> params) {

        return ownCommodityService.ownCommodityListPageData(params);
    }


    //添加操作
    @RequestMapping("/commodityAdd")
    public R addCommodity(Commodity commodity) {
        System.out.println(commodity);
        int result = ownCommodityService.addCommodity(commodity);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }



}
